#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Datetime: 2022/9/26 11:33
# @Author  : CHENWang
# @Site    : 
# @File    : weekly_whole_market_analysis.py
# @Software: PyCharm

"""
脚本说明:
"""

from TQR_Applications.factor_database.crypto.whole_market_analysis import drawdown_ratio
from logger import logger
import os
import traceback
from task_monitor import task_to_db, send_error_to_email


if __name__ == '__main__':
    # 分析全市场数据分析
    # 需要用到中的数据os.path.join(DATA_DIR, r'all_history_ohlcvm_coinmarketcap\all_history_ohlcvm_coinmarketcap')，
    # 因此需要等全市场各个币的数据获取完毕，再执行该任务, 时间设定为周六下午6点
    logger.info("开始计算drawdown_ratio")
    task_to_db(os.path.basename(__file__), 'drawdown_ratio')
    try:
        drawdown_ratio()
    except Exception as e:
        msg = traceback.format_exc()
        logger.info(msg)
        send_error_to_email(script_name=os.path.basename(__file__), func_name="drawdown_ratio", message=msg)
        raise e
    task_to_db(os.path.basename(__file__), 'drawdown_ratio', 1)
    logger.info("成功计算drawdown_ratio")